﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NopSolutions.NopCommerce.BusinessLogic.Data;
using NopSolutions.NopCommerce.BusinessLogic.Model;
using System.Data.Objects;

namespace NopSolutions.NopCommerce.BusinessLogic.Services
{
    public static class SettingCompiledQueries
    {
        public static readonly Func<NopObjectContext, IQueryable<Setting>> Settings =
            CompiledQuery.Compile<NopObjectContext, IQueryable<Setting>>(
                    (ctx) =>
                        from s in ctx.Settings
                        select s
            );

        public static readonly Func<NopObjectContext, int, Setting> SettingById =
            CompiledQuery.Compile<NopObjectContext, int, Setting>(
                    (ctx, id) =>
                        (from s in ctx.Settings
                         where s.SettingId == id
                         select s).FirstOrDefault()
            );
    }
}
